import { ariaEp } from './chore';
import { del_sameDF, del_eventTarget, del_sameDE, del_node } from './sameDFE';

const sameDH = {
  // -----------document and htmlElement ------------
  dir: '', // 行文方向
  hidden: false,
  title: '',
};
const sameWD = {
  captureEvents: function (): void {
    throw new Error('Function not implemented.');
  },
  close: function (): void {
    throw new Error('Function not implemented.');
  },
  getSelection: function (): Selection | null {
    throw new Error('Function not implemented.');
  },
  open: function (): Window | null {
    throw new Error('Function not implemented.');
  },
  releaseEvents: function (): void {
    throw new Error('Function not implemented.');
  },
};
const sameWH = {
  // w+h:
  blur: function (): void {
    throw new Error('Function not implemented.');
  },
  focus: function (): void {
    throw new Error('Function not implemented.');
  },
};

// =====================================
const myDocument = {
  // #region -
  URL: '',
  alinkColor: '',
  all: undefined,
  characterSet: '',
  charset: '',
  compatMode: '',
  contentType: '',
  cookie: '',
  currentScript: null,
  defaultView: null, // document 所在的window
  designMode: '', // 控制整个文档是否可编辑
  documentURI: '',
  domain: '',
  implementation: undefined,
  inputEncoding: '',
  lastModified: '',
  linkColor: '',
  readyState: 'complete',
  referrer: '',
  timeline: undefined,
  vlinkColor: '',
  createTreeWalker: function () {
    throw new Error('F遍历节点相关.');
  },
  createNodeIterator: function () {
    throw new Error('遍历节点相关.');
  },

  createEvent: function () {
    throw new Error('Function not implemented.');
  },
  createRange: function (): Range {
    throw new Error('Function not implemented.');
  },
  createNSResolver: function (nodeResolver: Node): Node {
    throw new Error('Function not implemented.');
  },
  hasFocus: function (): boolean {
    throw new Error('Function not implemented.');
  },
  hasStorageAccess: function (): Promise<boolean> {
    // 第三方cookie相关
    throw new Error('Function not implemented.');
  },
  requestStorageAccess: function (): Promise<void> {
    // 第三方cookie相关
    throw new Error('Function not implemented.');
  },
  activeElement: null,
  createExpression: function (expression: string, resolver?: XPathNSResolver | null | undefined): XPathExpression {
    throw new Error('Function not implemented.');
  },
  evaluate: function (
    expression: string,
    contextNode: Node,
    resolver?: XPathNSResolver | null | undefined,
    type?: number | undefined,
    result?: XPathResult | null | undefined
  ): XPathResult {
    throw new Error('Function not implemented.');
  },
  // #endregion
  ...del_sameDE,
  ...del_sameDF,
  ...sameDH,
  ...sameWD,
};

const myElement = {
  // #region -
  classList: undefined,
  className: '',
  id: '',
  part: undefined,
  shadowRoot: null,
  slot: '',
  tagName: '',
  attachShadow: function (init: ShadowRootInit): ShadowRoot {
    throw new Error('Function not implemented.');
  },
  closest: function <K extends keyof HTMLElementTagNameMap>(selector: K): HTMLElementTagNameMap[K] | null {
    throw new Error('Function not implemented.');
  },
  computedStyleMap: function (): StylePropertyMapReadOnly {
    throw new Error('Function not implemented.');
  },
  matches: function (selectors: string): boolean {
    throw new Error('Function not implemented.');
  },
  webkitMatchesSelector: function (selectors: string): boolean {
    throw new Error('Function not implemented.');
  },
  assignedSlot: null,
  // #endregion
  ...del_sameDE,
  ...ariaEp,
  ...sameWH,
};

const html_element = {
  // #region
  accessKey: '',
  accessKeyLabel: '',
  autocapitalize: '',
  draggable: false,
  lang: '',
  spellcheck: false,
  translate: false, // 好像是翻译相关
  attachInternals: function (): ElementInternals {
    throw new Error('Function not implemented.');
  },
  click: function (): void {
    throw new Error('Function not implemented.');
  },
  attributeStyleMap: undefined,
  style: undefined,
  contentEditable: '',
  enterKeyHint: '',
  inputMode: '',
  isContentEditable: false,
  autofocus: false,
  dataset: undefined,
  tabIndex: 0,
  // #endregion
  ...myElement,
  ...sameDH,
  ...sameWH,
};

// -----------------------------------------------------------------
const myWindow = {
  // 这些bar属性都仅仅返回是否可以visible而已，没啥用
  locationbar: undefined,
  menubar: undefined,
  personalbar: undefined,
  scrollbars: undefined,
  statusbar: undefined,
  toolbar: undefined,
  // #region
  clientInformation: undefined,
  closed: false,
  customElements: undefined, // todo 重要的实例 用于创建自定义元素
  event: undefined,
  external: undefined,
  frameElement: null, // 被嵌套时，引用当前window的frame
  frames: undefined,
  length: 0, // frames的数量
  name: '',
  navigator: undefined, // todo 重要的 Navigator
  opener: undefined, // window层级相关
  orientation: 0,
  parent: undefined,

  self: undefined, // 不要用window，用self，这样worker中也能正常运行
  speechSynthesis: undefined, // 话筒
  status: '',
  top: null, // 顶层window，还有parent
  window: undefined, // window.window === window
  cancelIdleCallback: function (handle: number): void {
    throw new Error('Function not implemented.');
  },
  getComputedStyle: function (elt: Element, pseudoElt?: string | null | undefined): CSSStyleDeclaration {
    throw new Error('Function not implemented.');
  },
  matchMedia: function (query: string): MediaQueryList {
    // 媒体查询？@？
    throw new Error('Function not implemented.');
  },
  postMessage: function (): void {
    throw new Error('Function not implemented.');
  },
  print: function (): void {
    throw new Error('Function not implemented.');
  },
  requestIdleCallback: function (callback: IdleRequestCallback, options?: IdleRequestOptions | undefined): number {
    throw new Error('Function not implemented.');
  },
  stop: function (): void {
    // 让正在加载的资源停止加载？
    throw new Error('Function not implemented.');
  },
  caches: undefined,
  crossOriginIsolated: false,
  crypto: undefined,
  isSecureContext: false,
  origin: '', // 当前域
  performance: undefined,
  atob: function (data: string): string {
    throw new Error('Function not implemented.');
  },
  btoa: function (data: string): string {
    throw new Error('Function not implemented.');
  },
  createImageBitmap: function (
    image: ImageBitmapSource,
    options?: ImageBitmapOptions | undefined
  ): Promise<ImageBitmap> {
    throw new Error('Function not implemented.');
  },
  fetch: function (input: URL | RequestInfo, init?: RequestInit | undefined): Promise<Response> {
    throw new Error('Function not implemented.');
  },
  queueMicrotask: function (callback: VoidFunction): void {
    throw new Error('Function not implemented.');
  },
  reportError: function (e: any): void {
    throw new Error('Function not implemented.');
  },
  structuredClone: function <T = any>(value: T, options?: StructuredSerializeOptions | undefined): T {
    throw new Error('Function not implemented.');
  },
  // #endregion
  ...del_eventTarget,
  ...sameWD,
  ...sameWH,
};

const myAttr = {
  name: '',
  value: '',
  ownerElement: null,
  specified: false,
  ...del_node,
};

const myChar = {
  ...del_node,
  data: '',
  length: 0,
  appendData: function (data: string): void {
    throw new Error('Function not implemented.');
  },
  deleteData: function (offset: number, count: number): void {
    throw new Error('Function not implemented.');
  },
  insertData: function (offset: number, data: string): void {
    throw new Error('Function not implemented.');
  },
  replaceData: function (offset: number, count: number, data: string): void {
    throw new Error('Function not implemented.');
  },
  substringData: function (offset: number, count: number): string {
    throw new Error('Function not implemented.');
  },
};

const myDoctype = {
  ...del_node,
  name: '',
  publicId: '',
  systemId: '',
};
